package ldh.im.fxbase.richtext;

import javafx.scene.Node;
import javafx.scene.image.ImageView;
import ldh.im.fxbase.emoji.ImageCache;

public class EmojiTextItem extends TextItem<EmojiTextItem> {

    private String emoji;

    public EmojiTextItem(String emoji) {
        this.emoji = emoji;
    }

    public Node createNode() {
        ImageView imageView = new ImageView();
        imageView.setImage(ImageCache.getInstance().getImage(ImageCache.getInstance().getImagePath(emoji)));
        imageView.setFitHeight(25);
        imageView.setFitWidth(25);
        return imageView;
    }

    public TextItemType getTextItemType() {
        return TextItemType.emoji;
    }

    @Override
    public boolean isNull() {
        if (emoji.equals("-1")) {
            return true;
        }
        return false;
    }

    @Override
    public String getData() {
        return getEmojiChar();
    }

    public String getEmojiChar() {
        return emoji;
    }
}
